package com.eos.control.action.activity;

import com.eos.business.service.SysActivityBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.common.tool.ObjectUtils;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SalesModel;
import com.eos.orm.mybatis.model.SysUser;

public class SaveBuyMethodAction extends AbstractBaseAction {
	private static final long serialVersionUID = -7510912390634725333L;
	private String salesName;
	//private String buyMethodDesc;

	public void setSalesName(String salesName) {
		this.salesName = salesName;
	}
	
	@Override
	public String execute() {
		try {
			SysUser user = (SysUser) getSession().getAttribute("SysUser");
			String userId = user.getId()+"";
			String strTime = ObjectUtils.formatDate(null, "yyyy-MM-dd HH:mm:ss");
			SalesModel saleModel = new SalesModel();
			saleModel.setSalesName(salesName);
			saleModel.setDealFlag(ConstantTool.DEAL_FALG_OK);
			saleModel.setInsertTime(strTime);
			saleModel.setInsertUserId(userId);
			saleModel.setUpdateUserId(userId);
			saleModel.setModifyTime(strTime);
			saleModel.setStatus(ConstantTool.STATUS_OK);
			SysActivityBusinessService sabs = new SysActivityBusinessService();
			String exeStatus = sabs.saveSalesModel(saleModel);
			if("SUCCESS".equals(exeStatus)){
				statusCode = "200";
				message = "新增销售方式信息成功!";
			}else{
				statusCode = "300";
				message = "系统繁忙, 新增销售方式信息失败!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常, 新增销售方式信息失败!";
		}
		return SUCCESS;
	}
	
	

}
